aboutdialog: Fix initial focus
authorMatthias Clasen <mclasen@redhat.com>
Sun, 17 Jan 2021 16:39:36 +0000 (11:39 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 17 Jan 2021 16:53:53 +0000 (11:53 -0500)
When GtkAboutDialog was changed to derive from
GtkWindow, it lost the initial focus handling that
GtkDialog has. Reinstate some of it.

Fixes: #3437
gtk/gtkaboutdialog.c

index 4cdee365758c086137fe574a152bc0c5e1e8472b..6e806856b2ecf53b261446b9a3f44e005d8359b1 100644 (file)
@@ -315,6 +315,17 @@ stack_visible_child_notify (GtkStack       *stack,
   return FALSE;
 }
 
+static void
+gtk_about_dialog_map (GtkWidget *widget)
+{
+  GtkAboutDialog *about = GTK_ABOUT_DIALOG (widget);
+
+  if (gtk_widget_get_visible (about->stack_switcher))
+    gtk_widget_grab_focus (gtk_widget_get_first_child (about->stack_switcher));
+
+  GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->map (widget);
+}
+
 static void
 gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
 {
@@ -329,6 +340,8 @@ gtk_about_dialog_class_init (GtkAboutDialogClass *klass)
 
   object_class->finalize = gtk_about_dialog_finalize;
 
+  widget_class->map = gtk_about_dialog_map;
+
   klass->activate_link = gtk_about_dialog_activate_link;
 
   /**